//返回顶部
returnTop($('.return-top'));

$('.index-banner-rule').click(() => {
    $('.index-vote-rule').fadeIn(400);
})

$('.index-vote-rule-close').click(() => {
    $('.index-vote-rule').fadeOut(400);
})

// localStorage.setItem('key', newNum);
// localStorage.getItem('key')
num = 10;
// 投票
$('.index-rank-vote-btn').click(function() {
    var text = $('.success-num span').text();
    var text1 = parseInt($(this).parent().siblings('.info').find('.num b').text());
    num--;
    if(num < 0) {
        showDialog('今日余票不足！');
        return false;
    }
    $('.success-num span').text(num);
    var newText = text1+1 +'票';
    $(this).parent().siblings('.info').find('.num b').text(newText);
    $('.index-vote-success').fadeIn(400);
})
$('.index-vote-success-close').click(() => {
    $('.index-vote-success').fadeOut(400);
})

// pay
$('.add').click(() => {
    var payNum = $('.pay-wrapper input').val();
    payNum = parseInt(payNum)+1;
    $('.pay-wrapper input').val(payNum);
    $('.price .num').text(payNum*120 +'.00');
})
$('.subtract').click(() => {
    var payNum = $('.pay-wrapper input').val();
    payNum = parseInt(payNum)-1;
    if(payNum < 1) {
        payNum = 1;
    }
    $('.pay-wrapper input').val(payNum);
    $('.price .num').text(payNum*120 +'.00');
})

$('.detail-form-btn').click(function() {
    var nameVal = $('.nicheng input').val();
    var infoVal = $('.info textarea').val();
    if(nameVal === "" || infoVal === "") {
        showDialog('信息不能为空哦！');
    }else{
        showDialogsuc('提交成功！！！');
    }
})